package com.example.a22310.myapplication.Beans;

import android.content.Intent;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.example.a22310.myapplication.Activity.TrainDetail;
import com.squareup.picasso.Picasso;

import java.io.Serializable;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class Train  extends BaseObservable implements Serializable {
        /**
         * id : 1
         * club_id : 2
         * name : 大连阳光俱乐部
         * train_picture : 1.jpg
         * train_intro : 旨在通过组织骑行运动，以“分享骑行乐趣”为主题，以“真诚、互助”为宗旨，旨在开展自行车的骑行和极限等活动，促进自行车文化发展，同时积极开拓户外运动，宣传环保，培养挑战自我的信心和勇气，宣传健康、简单的生活方式。是自行车运动爱好者的家园。
         * train_must : 1、进入健身区请穿运动鞋入内，区域内禁止嘻戏、打闹，严禁赤膊进入。 2、为了保证健身区内空气的清洁和您的身心健康，请不要吸烟、随地吐痰。 3、严禁酗酒后进入健身区。 4、切勿让小孩和不熟悉机器的人靠近或随意使用机器。 5、在运动和使用器材之前，请适当进行伸展和热身运动。
         * train_time : 2017-08-25 15:42:14
         * applynumber : 35
         * train_address : 大连星海广场
         * train_price : 299
         * flag : 1
         */
        private int id;
        private int club_id;
        private String name;
        private String train_picture;
        private String train_intro;
        private String train_must;
        private String train_time;
        private int applynumber;
        private String train_address;
        private String train_price;
        private int flag;

        public Train() {
        }

        public Train(int id, int club_id, String name, String train_picture,String train_intro,
                     String train_must,String train_time,int applynumber,String train_address,
                     String train_price,int flag) {
            this.id = id;
            this.club_id = club_id;
            this.name=name;
            this.train_picture = train_picture;
            this.train_intro = train_intro;
            this.train_must = train_must;
            this.train_time=train_time;
            this.applynumber = applynumber;
            this.train_address = train_address;
            this.train_price = train_price;
            this.flag=flag;
        }
        @BindingAdapter("train_picture")
        public static void loadInternetImage(ImageView iv, String train_picture) {
            Picasso.with(iv.getContext()).load(train_picture).into(iv);
        }

        @Override
        public String toString() {
            return "Train{" +
                    "id='" + id + '\'' +
                    ", club_id='" + club_id + '\'' +
                    ", name='" + name + '\'' +
                    "train_picture='" + train_picture + '\'' +
                    ", train_intro='" + train_intro + '\'' +
                    ", train_must='" + train_must + '\'' +
                    "train_time='" + train_time + '\'' +
                    ", applynumber='" + applynumber + '\'' +
                    ", train_address='" + train_address + '\'' +
                    "train_price='" + train_price + '\'' +
                    ", flag='" + flag + '\'' +
                    '}';
        }

        public void onItemClick(View view){
            Intent intent=new Intent(view.getContext(),TrainDetail.class);
            //往详情传递数据
            Train train=new Train();
            train.setId(getId());
            train.setFlag(getFlag());
            train.setClub_id(getClub_id());
            train.setTrain_picture(getTrain_picture());
            train.setName(getName());
            train.setTrain_intro(getTrain_intro());
            train.setTrain_must(getTrain_must());
            train.setTrain_time(getTrain_time());
            train.setTrain_price(getTrain_price());
            train.setTrain_address(getTrain_address());
            intent.putExtra("train",train);
            view.getContext().startActivity(intent);
        }


        @Bindable
        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public int getClub_id() {
            return club_id;
        }

        public void setClub_id(int club_id) {
            this.club_id = club_id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getTrain_picture() {
            return IMG_URL+train_picture;
        }

        public void setTrain_picture(String train_picture) {
            this.train_picture =train_picture;
        }

        public String getTrain_intro() {
            return train_intro;
        }

        public void setTrain_intro(String train_intro) {
            this.train_intro = train_intro;
        }

        public String getTrain_must() {
            return train_must;
        }

        public void setTrain_must(String train_must) {
            this.train_must = train_must;
        }

        public String getTrain_time() {
            return train_time;
        }

        public void setTrain_time(String train_time) {
            this.train_time = train_time;
        }

        public int getApplynumber() {
            return applynumber;
        }

        public void setApplynumber(int applynumber) {
            this.applynumber = applynumber;
        }

        public String getTrain_address() {
            return train_address;
        }

        public void setTrain_address(String train_address) {
            this.train_address = train_address;
        }

        public String getTrain_price() {
            return train_price;
        }

        public void setTrain_price(String train_price) {
            this.train_price = train_price;
        }

        public int getFlag() {
            return flag;
        }

        public void setFlag(int flag) {
            this.flag = flag;
        }
    }
